package zhang.lao.pojo.console;


import zhang.lao.pojo.console.login.LoginUserModel;

import java.util.List;

/**
 * Created by tech6 on 2016/8/23.
 */
public class ConsoleContext {


    private LoginUserModel loginUserModel;
    private String companyId;
    private String companyName;
    private List<String> farms;
    private String farmsInSql;
    private String client;
    public boolean isPhone() {
        return client.equals("phone");
    }

    public String getClient() {
        return client;
    }

    public void setClient(String client) {
        this.client = client;
    }

    public String getFarmsInSql() {
        if(farms!=null&&farms.size()>0) {
            StringBuffer stringBuffer = new StringBuffer(" in (");
            for (int i = 0; i < farms.size(); i++) {
                String shjdId = farms.get(i);
                stringBuffer.append("'" + shjdId + "'");
                if (i != farms.size() - 1) {
                    stringBuffer.append(",");
                }
            }
            stringBuffer.append(") ");
            farmsInSql=stringBuffer.toString();
        }
        return farmsInSql;
    }

    public void setFarmsInSql(String farmsInSql) {

        this.farmsInSql = farmsInSql;
    }

    public LoginUserModel getLoginUserModel() {
        return loginUserModel;
    }

    public String getCompanyId() {
        return companyId;
    }

    public void setCompanyId(String companyId) {
        this.companyId = companyId;
    }

    public String getCompanyName() {
        return companyName;
    }

    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }


    public void setLoginUserModel(LoginUserModel loginUserModel) {
        this.loginUserModel = loginUserModel;
    }

    public List<String> getFarms() {
        return farms;
    }

    public void setFarms(List<String> farms) {
        this.farms = farms;
    }

    public String getUserId(){
        if(loginUserModel==null){
            return null;
        }else{
            return loginUserModel.getUser_id();
        }
    }
    public String getStrUserId(){
        if(loginUserModel==null){
            return null;
        }else{
            return loginUserModel.getUser_id();
        }
    }
}
